package fag.core.game.test.asteroids;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

import fag.core.geometry.Circle2D;
import fag.core.geometry.Vector2D;
import fag.core.model.Animation;
import fag.core.model.Frame;
import fag.core.model.Model;
import fag.core.model.SerializableImage;
import fag.core.model.Sprite;

@SuppressWarnings("serial")
public class MeteoriteModel extends Model {
	
	public MeteoriteModel() {
		loadMeteoriteModel("meteorite_1.png");
		loadMeteoriteModel("meteorite_2.png");
		loadMeteoriteModel("meteorite_3.png");
	}
	
	private void loadMeteoriteModel(String name) {
		
		BufferedImage bi = null;
		try {
			bi = ImageIO.read(new File(System.getProperty("user.dir") + "/src/imgs/asteroids/" + name));
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		Frame f = new Frame();
		f.setSprite(new Sprite(new SerializableImage(bi), new Vector2D()));
		f.getSprite().setOffset(new Vector2D(-f.getSprite().getWidth() / 2, -f.getSprite().getHeight() / 2));
		f.setHitbox(new Circle2D(0, 0, f.getSprite().getWidth() / 2));
		f.updateBounds();
		
		Animation a = new Animation(name);
		a.addFrame(f);
		getListAnimation().add(a);
	}
}